import { getVisualInfo, getTestDataInfo } from '@/api/visual'
const visual = {
  state: {
    visualData: [],
    testData: []
  },
  mutations: {
    SET_VISUALDATA: (state, visualData) => {
      state.visualData = visualData
    },
    SET_TESTDATA: (state, testData) => {
      state.testData = testData
    }
  },

  actions: {

    // 总体数据可视化
    VisualGetInfo({ commit }) {
      return new Promise((resolve, reject) => {
        console.log('VisualGetInfo')
        getVisualInfo().then(response => {
          console.log('getInfo')
          const data = response.data
          commit('SET_VISUALDATA', data)
          console.log(data)
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    },
    // 关键指标数据可视化
    TestDataGetInfo({ commit }) {
      return new Promise((resolve, reject) => {
        console.log('TestDataGetInfo')
        getTestDataInfo().then(response => {
          console.log('getInfo')
          const data = response.data
          commit('SET_TESTDATA', data)
          console.log(data)
          resolve(response)
        }).catch(error => {
          reject(error)
        })
      })
    }
  }
}

export default visual
